package com.xl.controller;


import com.alibaba.fastjson.JSON;
import com.xl.endpoint.WSEndPoint;
import com.xl.pojo.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ws")
public class ChatController {

    @Autowired
    private WSEndPoint wsEndPoint;
    @PostMapping("/send")
    public void sendToOne(@RequestBody Msg msg){
        System.out.println("controller recc :" + JSON.toJSONString(msg));
        wsEndPoint.sendToClient(msg.getUserId() , msg.getMsg());
    }


}
